'EViews Programming Code for Hong Kong

wfopen  "C:\Users\Maryam\Desktop\BS Studies\PhD Thesis-II\EViews and STATA Progarm Codes\Chapter-7\Hong Kong.wf1"

'****************************************************************************
'Group Plot for pNTpT_HK3, RER_DEF, RER_DEF_NT and aTaNT_HK3
'****************************************************************************
group gA PNT_PT_3 AT_ANT_3
freeze(group_plot) gA.line(x)
group_plot.setelem(1) lcolor(black) symbol(7) lpat(1)
group_plot.setelem(2) lcolor(black) symbol(4) lpat(1)
group_plot.setelem(3) lcolor(black) symbol(1) lpat(1)
group_plot.setelem(3) lcolor(black)
group_plot.options linepat
group_plot.addtext(t) Sectoral Prices and Productivity Gap (Hong Kong & U.S): 1980-2008
group_plot.addtext(b) Year
group_plot.addtext(l) PNT_PT_3
group_plot.addtext(r) AT_ANT_3
'************************************************************
'************************************************************
create y 1980 2008
'importing data from Excel for Hong Kong
import  "C:\Users\Maryam\Desktop\BS Studies\PhD Thesis-II\EViews and STATA Progarm Codes\Chapter-7\Chapter 7.xlsx" range="Hong Kong"
'***************************************************************************************************
'CASE-1: ESTIMATING BALASSA-SAMUELSON EFFECT FOR pNTpT_HK3 & aTaNT_HK3
'***************************************************************************************************
'*************************************************************
'STEP 0: Tests for Unit Root in Individual Time Series
'*************************************************************
'****************************************
'Graph for Hong Kong's pNTpT_HK3
'****************************************
                                        
genr pNTpT_HK3 = pNTpT_HK3
freeze(figure_pNTpT_HK3) pNTpT_HK3.line
figure_pNTpT_HK3.addtext(t) pNTpT_HK3 (Hong Kong):  1980-2008
figure_pNTpT_HK3.addtext(b) Year
figure_pNTpT_HK3.addtext(l) pNTpT_HK3
figure_pNTpT_HK3.legend(off)
                                                 
'We see from the FIGURE that pNTpT_HK3 has time trend to it.  So we would include both an intercept and a time trend in our unit root regression equations. 

'******************************************************
'ADF Unit Root Test for Hong Kong's pNTpT_HK3
'******************************************************
 
freeze(table_7_11_pNTpT_HK3_adf) pNTpT_HK3.uroot(adf,trend,info=sic)

'Note that automatic lag selection picks, p = 0, since the automatic lag selection was picking abnormally high number of lags (p=6).  The unit root test produces a t-value of -2.42 which is greater than our 5% criterion -3.59.  Thus, at this point, we cannot reject the null of a unit root.

'Now, let's check for white noise.  To do that, I first set all the residuals = 0, then run the ADF test and finally will check for white noise.

genr resid = 0
freeze(mode=overwrite,pNTpT_HK3_adf) pNTpT_HK3.uroot(adf,const,trend,info=sic)
freeze(pNTpT_HK3_adf_correl) resid.correl
 
'Based on the Q-statistic, I conclude that the residuals are white noise.  Putting it all together, I conclude that the pNTpT_HK3 series is not level stationary.

'The next thing I do is test whether the differenced series is stationary using the ADF test.  I once again begin by graphing the (differenced) series.
 
genr pNTpT_HK3diff = d(pNTpT_HK3)
freeze(figure_pNTpT_HK3diff) pNTpT_HK3diff.line
figure_pNTpT_HK3diff.addtext(t) dpNTpT_HK3 (Hong Kong):  1980-2008
figure_pNTpT_HK3diff.addtext(b) Year
figure_pNTpT_HK3diff.addtext(l) DpNTpT_HK3
figure_pNTpT_HK3diff.legend(off)

'From the graph, the series clearly does not have a time trend to it. So, I would test the series for unit with an intercept only.

'So we begin the whole process over again: 

genr pNTpT_HK3diff = d(pNTpT_HK3)
freeze(table_7_11_pNTpT_HK3diff1_adf) pNTpT_HK3diff.uroot(adf,const,info=sic)

'Note that the SIC automatic lag selection picks no lags, p =0.  The unit root test produces a t-value of -5.92 which is smaller than our 5% criterion -2.98.  Thus, we may nowreject the null of non-stationarity in first differenced series of pNTpT_HK3.  There is no reason to go further.  The last thing we do is to check ADF regression result for white noise.

genr resid = 0
freeze(mode=overwrite,pNTpT_HK3diff1_adf) pNTpT_HK3diff.uroot(adf,const,info=sic)
freeze(pNTpT_HK3diff1_adf_correl) resid.correl

''Based on the Q-statistic, I conclude that the residuals are white noise.  Putting it all together, I conclude that the pNTpT_HK3 series is I(1).

'**********************************************************
'DF-GLS Unit Root Test for Hong Kong's pNTpT_HK3
'**********************************************************
 
freeze(table_7_11_pNTpT_HK3a_dfgls) pNTpT_HK3.uroot(dfgls,trend,info=sic)

'Note that the SIC automatic lag selection picks lags, p = 0.  The unit root test produces a t-value of -2.52 which is greater than our 5% criterion -3.19.  Thus, at this point, we may not reject the null of unit root.

'Now let's see if the series is difference stationary or not

genr pNTpT_HK3diff = d(pNTpT_HK3)
freeze(table_7_11_pNTpT_HK3bdiff1_dfgls_d) pNTpT_HK3diff.uroot(dfgls,const,info=sic)

'Note that the SIC automatic lag selection picks no lags, p = 0.  The unit root test produces a t-value of -6.00 which is now smaller than our 5% criterion -1.95. Thus, we may reject the null of non-stationarity in first differenced series of pNTpT_HK3.  

''Putting it all together, I conclude that the pNTpT_HK3 series is greater than I(1), a finding compatible with my ADF test results.

'******************************************************
'Graph for Hong Kong's Productivity (aTaNT_HK3)
'******************************************************
                                        
genr aTaNT_HK3 = aTaNT_HK3
freeze(figureaTaNT_HK3) aTaNT_HK3.line
figureaTaNT_HK3.addtext(t) aTaNT_HK3 (Hong Kong):  1980-2008
figureaTaNT_HK3.addtext(b) Year
figureaTaNT_HK3.addtext(l) aTaNT_HK3
figureaTaNT_HK3.legend(off)
                                                 
'We see from the FIGURE that aTaNT_HK3 has time trend to it.  So we would include both an intercept and a time trend in our unit root regression equations. 

'*******************************************************
'ADF Unit Root Test for Hong Kong's Productivity
'*******************************************************
 
freeze(table_7_11_aTaNT_HK3_adf) aTaNT_HK3.uroot(adf,trend,info=sic)

'Note that the SIC automatic lag selection picks lags, p =2.  The unit root test produces a t-value of -2.03 which is greater than our 5% criterion -3.59.  Thus, at this point, we cannot reject the null of a unit root.

'Now, let's check for white noise.  To do that, I first set all the residuals = 0, then run the ADF test and finally will check for white noise.

genr resid = 0
freeze(mode=overwrite,aTaNT_HK3_adf) aTaNT_HK3.uroot(adf,const,trend,info=sic)
freeze(aTaNT_HK3_adf_correl) resid.correl
 
'Based on the Q-statistic, I conclude that the residuals are white noise.  Putting it all together, I conclude that the aTaNT_HK3 series is not level stationary.

'The next thing I do is test whether the differenced series is stationary using the ADF test.  I once again begin by graphing the (differenced) series.
 
genr aTaNT_HK3diff = d(aTaNT_HK3)
freeze(figure_aTaNT_HK3diff) aTaNT_HK3diff.line
figure_aTaNT_HK3diff.addtext(t) daTaNT_HK3 (Hong Kong):  1980-2008
figure_aTaNT_HK3diff.addtext(b) Year
figure_aTaNT_HK3diff.addtext(l) DaTaNT_HK3
figure_aTaNT_HK3diff.legend(off)

'From the graph, the series clearly does not have a time trend to it. So, I would test the series for unit with an intercept only.

'So we begin the whole process over again: 

genr aTaNT_HK3diff = d(aTaNT_HK3)
freeze(table_7_11_aTaNT_HK3diff1_adf) aTaNT_HK3diff.uroot(adf,const,info=sic)

'Note that the SIC automatic lag selection picks no lags, p =0.  The unit root test produces a t-value of -5.52 which is now smaller than our 5% criterion -2.98.  Thus, we may now reject the null of non-stationarity in first differenced series of aTaNT_HK3. There is no reason to go further. The last thing we do is to check ADF regression result for white noise.

genr resid = 0
freeze(mode=overwrite,aTaNT_HK3diff1_adf) aTaNT_HK3diff.uroot(adf,const,info=sic)
freeze(aTaNT_HK3diff1_adf_correl) resid.correl

''Based on the Q-statistic, I conclude that the residuals are white noise.  Putting it all together, I conclude that the aTaNT_HK3 series is I(1).

'************************************************************
'DF-GLS Unit Root Test for Hong Kong's Productivity
'************************************************************
 
freeze(table_7_11_aTaNT_HK3_dfgls) aTaNT_HK3.uroot(dfgls,trend,info=sic)

'Note that the SIC automatic lag selection picks lags, p = 2.  The unit root test produces a t-value of -2.05 which is greater than our 5% criterion -3.19.  Thus, at this point, we may not reject the null of a unit root.
 
'Now let's see if the series is difference stationary or not

genr aTaNT_HK3diff = d(aTaNT_HK3)
freeze(table_7_11_aTaNT_HK31diff1_dfgls) aTaNT_HK3diff.uroot(dfgls,const,info=sic)

'Note that the SIC automatic lag selection picks no lags, p = 0.  The unit root test produces a t-value of -4.66 which is smaller than our 5% criterion -1.95. Thus, we may reject the null of non-stationarity in first differenced series of aTaNT_HK3.  

''Putting it all together, I conclude that the aTaNT_HK3 series is I(1), a finding compatible with my ADF test results.

'*********************************************
'Single Equation Cointegration Methods
'*********************************************

'**********************************************************
''Graph the suspected cointegrated series together
'**********************************************************

'The first step is to plot a graph of the suspected series.  This is very important!

group g1 pNTpT_HK3 aTaNT_HK3
freeze(figure7_11a) g1.line(x)
figure7_11a.setelem(1) lcolor(black) 
figure7_11a.setelem(2) lcolor(black) lpat(8)
figure7_11a.options linepat
figure7_11a.addtext(t) pNTpT_HK3 and aTaNT_HK3 (Hong Kong & U.S): 1980-2008
figure7_11a.addtext(b) Year
figure7_11a.addtext(l) pNTpT_HK3
figure7_11a.addtext(r) aTaNT_HK3

''*******************************************************
''S1.A.Engle-Granger Approach to Cointegration
'*******************************************************
 
freeze(table_7_11_egc) g1.coint(method=eg)

'The null hypothesis will be rejected as suggested by sample statistics.

''******************************************
''S1.B.Error Correction Model (ECM)
'*******************************************
''**********************************************
'Selecting the number of lags in the VAR
'***********************************************

'NOTE: We do this because we need to have the "right" number of lags when it comes time to estimate our VEC model and test for cointegration.

var table_7_11_var1.ls 1 4   g1
freeze(table_7_11_var1_lagtest1) table_7_11_var1.laglen(4)
freeze(table_7_11_var1_lagtest2) table_7_11_var1.testlags

'The laglength test above indicates that the VAR has 1 lag.
 
var table_7_11_var2.ls 1 1  g1
freeze(table_7_11_var2_artest1) table_7_11_var2.correl
freeze(table_7_11_var2_artest2) table_7_11_var2.qstats(12)
freeze(table_7_11_var2_artest3) table_7_11_var2.arlm(12)

'The residuals are absolutely white noise.

'We now try different lags of d(aTaNT_HK3), comparing SIC values across specifications.

genr resid = 0
equation eg.ls pNTpT_HK3 c aTaNT_HK3
genr ec = resid

var table_7_11_eg2a.ls 0 0 d(pNTpT_HK3)   @  c ec(-1) d(pNTpT_HK3(-1)) 

var table_7_11_eg2b.ls 0 0 d(pNTpT_HK3)   @  c ec(-1) d(pNTpT_HK3(-1)) d(aTaNT_HK3(-1))

var table_7_11_eg2c.ls 0 0 d(pNTpT_HK3)   @  c ec(-1) d(pNTpT_HK3(-1)) d(aTaNT_HK3(-1)) d(aTaNT_HK3(-2))

'The evidence suggests that Model C is best.  Now we test that model for serial correlation.

var table_7_11_eg2c.ls 0 0 d(pNTpT_HK3)   @   c ec(-1) d(pNTpT_HK3(-1)) d(aTaNT_HK3(-1)) d(aTaNT_HK3(-2))
freeze(table_7_11_eg2c1_artest1) table_7_11_eg2c.correl
freeze(table_7_11_eg2c2_artest2) table_7_11_eg2c.qstats(12)
freeze(table_7_11_eg2c3_artest3) table_7_11_eg2c.arlm(12)

'The residuals are absolutely white noise.

''*************************
''Estimating EC Model  
'**************************

'We'll now take the above specified model and turn it into an ECM. We shall run NW-HAC least squares model for establishing error correction mechanism.

'We now estimate the corresponding ECM:

equation table_7_11_ecm.ls(n) d(pNTpT_HK3) c ec(-1) d(pNTpT_HK3(-1)) d(aTaNT_HK3(-1)) d(aTaNT_HK3(-2))

'Note that the SR effect is significant as the error correction coefficient -0.81 is statistically significant.

''**********************************************
''S2.A & S2.B: Obtaining LR Coefficients
'***********************************************
'Now, by employing FMOLS and DOLS cointegration regression estimators, finally we shall calculate our LR coefficient i.e. BS coefficient for Hong Kong against U.S.

equation table_7_11_LReqn_fmols.cointreg(method=fmols) pNTpT_HK3 aTaNT_HK3

equation table_7_11_LReqn_dols.cointreg(method=dols, trend=constant, lag=2,lead=2 ) pNTpT_HK3 aTaNT_HK3

'The BS coefficient obtained through FMOLS and DOLS estimators are -0.20 and -0.21, i.e., the long run BS coefficients are bearing undired signs. Thus, there is 'NO' evidence in support of BS effect existing for Hong Kong.

''******************************************
'Multivariate Cointegration Approach
'******************************************

''********************************************************
''Check if the VAR (2) model is dynamically stable
'*********************************************************
freeze(table_7_11_var2_varstable) table_7_11_var2.arroots(graph)

'The model is dynamically stable.

''**********************************************************************
''M1.A & M1.B: Identifying the number of cointegrating vectors
'***********************************************************************

'Having identified the appropriate number of lags to put in, I now go on to test for the appropriate number of cointegrating equations.

freeze(table_7_11_var2_coint) table_7_11_var2.coint(s,1)

'This command estimates all possible combinations of constants and trends in the level data series and the cointegrating equations. All the results indicate 0 cointegrating vectors.
'
'GENERAL NOTE:, in practice, cases 1 and 5 are rarely used. One should use case 1 only if one knows that all series have zero mean. Case 5 may provide a good fit in-sample but will produce implausible forecasts out-of-sample. As a rough guide, use case 2 if none of the series appear to have a trend. For trending series, use case 3 if you believe all trends are stochastic; if you believe some of the series are trend stationary, use case 4.

'Note that the 5 cases are identified under "Johansen cointegration test" in EViews. They run from most restrictive (no constants in either the level series or CEs) to most general (trend terms in both the level series and CEs).

'CONCLUSION:  I conclude that pNTpT_HK3 and aTaNT_HK3 are not cointegrated in the Hong Kong's data.

